package sketch.generator.experiment;

import java.util.LinkedList;
import java.util.List;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class BasicValuesTest extends TestCase {
	
	public static Test suite() {
		return new TestSuite(BasicValuesTest.class);
	}
	
	public void testEmptyValue() {
		ValueGroup<Integer> g = new EmptyValue<Integer>();
		assertTrue(g.isEmptyData());
		assertTrue(!g.isMultiData());
		assertTrue(!g.isSingleData());
		
		assertTrue(g.getData().isEmpty());

	}
	
	public void testSingleValue() {
		ValueGroup<Integer> g = new SingleValue<Integer>(1);
		assertTrue(!g.isEmptyData());
		assertTrue(!g.isMultiData());
		assertTrue(g.isSingleData());
		
		assertTrue(g.getData().size() == 1);
	}
	
	public void testMultiValue() {
		Integer[] xs = new Integer[]{1,2,3,4};
		ValueGroup<Integer> g = new MultiValue<Integer>(xs);
		assertTrue(!g.isEmptyData());
		assertTrue(g.isMultiData());
		assertTrue(!g.isSingleData());
		
		assertTrue(g.getData().size() == xs.length);
		
		g = new MultiValue<Integer>();
		assertTrue(g.getData().size() == 0);
	}
	
	public void testError() {
		try {
			new SingleValue<Integer>(1,2);
			fail();
		} catch (AssertionError e) {
			
		}
		
		try {
			List<Integer> l = new LinkedList<Integer>();
			l.add(1);
			l.add(2);
			new SingleValue<Integer>(l);
			fail();
		} catch (AssertionError e) {
			
		}
	}
	
}
